<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="./lib/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
    <!-- <p v-for="item in list">{{item}}</p>
    <p v-for="(item,i) in list">{{item.id}}---{{i}}</p>
    <p v-for="(user,i) in list">Id: {{user.id}}---名字:{{user.name}}----索引:{{i}}</p> -->
    <div>
    id:<input type="text" v-model="userID">
    name:<input type="text" v-model="userName">
    <input type="button" value="添加" @click="add()">
    </div>
    <div>
    <p v-for="(item,index) in list" :key="item.id">

    {{ item.id }} ------- {{ item.name }}
    </p>
    </div>
</body>
<script>
    var vm = new Vue({
        el:"#app",
        data:{
            list:[
                {id:1,name:"张三"},
                {id:2,name:"李四"},
                {id:3,name:"王五"}
            ]
        },
        methods:{
            add:function(){
                this.list.unshift({
                    id:this.userID,
                    name:this.userName
                })
                
            }
        },
    }
        

    )

    
</script>
</html>